package hongcaosp.app.android.user.settings.wallet.presenter;

import android.text.TextUtils;

import hongcaosp.app.android.login.UserToken;
import hongcaosp.app.android.modle.BaseResponse;
import hongcaosp.app.android.modle.DataCallBack;
import hongcaosp.app.android.modle.impl.UserWalletModelImpl;
import hongcaosp.app.android.user.settings.wallet.iview.AccountBindIView;
import xlj.lib.android.base.component.BasePresenter;
import xlj.lib.android.base.toastcompat.ToastManager;

/**
 * 提现账号绑定
 */
public class AccountBindPresenter extends BasePresenter {

    private AccountBindIView view;

    private UserWalletModelImpl userWalletModel;

    public AccountBindPresenter(AccountBindIView view) {
        this.view = view;
        userWalletModel = new UserWalletModelImpl();
    }

    /**
     * 绑定提现账号
     * @param type
     * @param account
     */
    public void bindingPayType(int type, String account) {
        if (TextUtils.isEmpty(account)) {
            ToastManager.getInstance().showToast("请输入收款账号");
            return;
        }
        userWalletModel.bindingPayType(UserToken.getDefault().getToken(), type, account, new DataCallBack<BaseResponse>() {
            @Override
            public void onGetData(BaseResponse data) {
                super.onGetData(data);
                view.cashWithdrawalRst(data);
            }

            @Override
            public void onFail(int code, String errorMessage) {
                super.onFail(code, errorMessage);
                ToastManager.getInstance().showToast(errorMessage);
            }
        });
    }
}
